//
//  QXMainTabBarViewController.swift
//  DanTangSwift
//
//  Created by 众力金融 on 2017/6/16.
//  Copyright © 2017年 众力金融. All rights reserved.
//

import UIKit

class QXMainTabBarViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        let tabBar = UITabBar.appearance()
        tabBar.tintColor = UIColor.QXTabBarItemtintColor
        
        addChildViewControllers()
        
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
  private func addChildViewControllers() {
        addChildViewController(childController: QXHomeBaseViewController(), title: "单糖", imageName: "TabBar_home_23x23_")
        addChildViewController(childController: QXSingleProductViewController(), title: "单品", imageName: "TabBar_gift_23x23_")
        addChildViewController(childController: QXClassifyViewController(), title: "分类", imageName: "TabBar_category_23x23_")
        addChildViewController(childController: QXMeViewController(), title: "我的", imageName: "TabBar_me_boy_23x23_")
    }
   
   /// 初始化子控制器
   ///
   /// - Parameters:
   ///   - childController: 需要初始化的控制器
   ///   - title: 标题
   ///   - imageName: 图片的名称
   private func addChildViewController(childController: UIViewController, title: String, imageName: String) {
        childController.tabBarItem.image = UIImage(named: imageName)
        childController.tabBarItem.selectedImage = UIImage(named: imageName + "selected")
        childController.title = title
        let nacV = QXBaseNavigationViewController(rootViewController: childController)
        addChildViewController(nacV)
    // childController.tabBarItem.selectedImage = UIImage(named: selImage)?.withRenderingMode(UIImageRenderingMode.alwaysOriginal)
        
    }

}
